﻿@model IEnumerable<DNA.Mvc.Management.EventLogEntry>
@{
    Layout = "~/Views/Shared/_Dashboard.cshtml";
}
@UIHelper.ImageTitle(Html.Global("RES_LOGVIEWER"),"", Url.Content("~/content/images/icon_health_48.png"))
@{
    var errorCodes = new int[] { 3000, 3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009, 3010, 3011, 4005, 4006, 4007, 4008, 4009, 4010, 4011, 50014, 50016, 50201, 50202 };
    
}
@{
    if (Model.Count() > 0)
    {
        using (Html.BeginForm())
        {
    <p>
        @Ajax.Dna().Button().Submit().ImageIcons(Url.Content("~/content/images/icon_dustbin_16.gif")).LocText(Html.Global("Heath_ClearLog")).GetHtml()
    </p>
        }

        Ajax.Dna().Grid(Model)
           .Columns(cols =>
           {
               cols.Bound(m => m.EventType).Template(@<text>
    @{
        var imgUrl = "~/content/images/{0}";
        var category = "Information";
        if (!string.IsNullOrEmpty(item.ExceptionType) || errorCodes.Contains(item.EventCode))
        {
            imgUrl = string.Format(imgUrl, "icon_stop.gif");
            category = "Error";
        }
        else
        {
            imgUrl = string.Format(imgUrl, "icon_info_16.png");
        }
    }
    <img src="@Url.Content(imgUrl)" alt="" />@category
    </text>).Width(100).Title(Html.Global("RES_LEVEL"));
               cols.Bound(m => m.EventTime).Width(150).Title(Html.Global("RES_LOG_TIME"));
               cols.Bound(m => m.EventCode).Title(Html.Global("Log_EventID"));
               cols.Bound(m => m.EventDetailCode).Title(Html.Global("Log_EventCode"));
               cols.Bound(m => m.Message).Title(Html.Global("RES_MESSAGE"));
           })
               .DetailView(@<text>
    <div style="white-space: normal; padding: 10px; margin: 5px;" class="ui-state-highlight">
        @MvcHtmlString.Create(item.Detail.Replace("\n", "<br/>"))</div>
    </text>)
           .Pagable()
           .Render();
    }
    else
    {
    <div style="padding:10px;">
        @Html.Global("Log_NoData")</div>
    }
}
